const requests=require('requests')
const fs = require('fs');
const path = require('path');
const cheerio = require('cheerio')

let url = 'https://ncov.dxy.cn/ncovh5/view/pneumonia?from=timeline&isappinstalled=0';

requests(url).on('data',function (chunk) {
  //console.log(chunk);
  let window={}
  const $=cheerio.load(chunk)
  const html=$('#getAreaStat').html()
  eval(html)//用js方法执行字符串
  fs.writeFile(path.resolve(__dirname,'index.json'),JSON.stringify(window.getAreaStat),()=>{
    console.log('保存成功');
    
  })
})